<template>
	<!-- 空登陆页 -->
	<view>login page </view>
</template>

<script setup>
	import { isEmpty } from 'lodash';
	import { onLoad, onShow } from '@dcloudio/uni-app';
	import $platform from '/shop/platform/index.js';
	import userStore from '/shop/store/user.js';

	onLoad(async (options) => {

		// #ifdef H5
		let event = '';
		if (options.login_code) {
			event = 'login';
			const { code } = await $platform.useProvider().login(options.login_code);
			if (code === '0') {
				userStore().getInfo();
			}
		}
		if (options.bind_code) {
			event = 'bind';
			const { code } = await $platform.useProvider().bind(options.bind_code);
		}

		// 检测H5登录回调
		let returnUrl = uni.getStorageSync('returnUrl');
		if (returnUrl) {
			uni.removeStorage('returnUrl');
			location.replace(returnUrl);
		} else {
			uni.switchTab({
				url: '/',
			});
		}

		// #endif
	});
</script>
